package com.care.wardmate.server.controller;

import com.care.common.core.domain.Result;
import com.care.common.core.result.PageResult;
import com.care.wardmate.common.domain.Article;
import com.care.wardmate.common.request.ArticleRequest;
import com.care.wardmate.server.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author 33253
 */
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @PostMapping("/selectArticle")
    public Result<PageResult<Article>> selectArticle(@RequestBody ArticleRequest articleRequest){
         PageResult<Article> result = articleService.selectArticle(articleRequest);
         return Result.success(result);
    }
    @GetMapping("/selectArticleById/{articleId}")
    public Result<Article> selectArticleById(@PathVariable Integer articleId){
        Article result = articleService.selectArticleById(articleId);
        return Result.success(result);
    }
    @PostMapping("/insertArticleByUserId")
    public Result insertArticleByUserId(@RequestBody Article article){
        articleService.insertArticleByUserId(article);
        return Result.success();
    }

}
